import json
import os

import logging

import requests


def get_btn(device_id):

    print("get_btn")
    data = {
        'device_id': device_id,
    }

    # 获取当前脚本的文件路径
    current_file_path = os.path.abspath(__file__)

    # 获取当前脚本所在的文件夹路径
    current_directory = os.path.dirname(current_file_path)

    # 读取 JSON 文件
    with open(current_directory + '/local_config.json', 'r') as file:
        config = json.load(file)
    # 访问配置数据

    url = config["url"] + "/get_btn"

    response = requests.post(url, json=json.dumps(data))

    text = response.text

    return text




def ai_btn_mate(user_massage):
    data = {
        'user_massage': user_massage,
    }

    # 获取当前脚本的文件路径
    current_file_path = os.path.abspath(__file__)

    # 获取当前脚本所在的文件夹路径
    current_directory = os.path.dirname(current_file_path)

    # 读取 JSON 文件
    with open(current_directory + '/local_config.json', 'r') as file:
        config = json.load(file)
    # 访问配置数据

    url = config["url"] + "/ai_btn_mate"

    response = requests.post(url, json=json.dumps(data))

    text = response.text

    return text


if __name__ == "__main__":

    # print(ai_btn_mate("喜欢这种姿势吗"))

    get_btn("xiaomi6")

    print(get_btn("xiaomi6"))




